package etc.utils.ftp;

import cn.hutool.extra.ftp.Ftp;
import com.dmz.common.utils.secure.GMUtil;
import com.dmz.etc.server.config.EnvConfig;
import lombok.Data;

/**
 * @author lee
 */
@Data
public class FtpClient {
    private String host;

    private int port;

    private String username;

    private String password;

    public Ftp etcFtp() {
        String key = EnvConfig.getProperty("sm4.key");
        String iv = EnvConfig.getProperty("sm4.iv");
        this.host = EnvConfig.getProperty("dmz.ftp.etc.host");
        this.port = Integer.valueOf(EnvConfig.getProperty("dmz.ftp.etc.port"));
        this.username = GMUtil.db(key, iv, EnvConfig.getProperty("dmz.ftp.etc.username"));
        this.password = GMUtil.db(key, iv, EnvConfig.getProperty("dmz.ftp.etc.password"));
        return new Ftp(host, port, username, password);
    }

    public Ftp bankFtp() {
        String key = EnvConfig.getProperty("sm4.key");
        String iv = EnvConfig.getProperty("sm4.iv");
        this.host = EnvConfig.getProperty("dmz.ftp.bank.host");
        this.port = Integer.valueOf(EnvConfig.getProperty("dmz.ftp.bank.port"));
        this.username = GMUtil.db(key, iv, EnvConfig.getProperty("dmz.ftp.bank.username"));
        this.password = GMUtil.db(key, iv, EnvConfig.getProperty("dmz.ftp.bank.password"));
        return new Ftp(host, port, username, password);
    }
}
